package com.zdkj.subway.rca.util;

import com.alibaba.excel.converters.*;
import java.time.*;
import com.alibaba.excel.enums.*;
import com.alibaba.excel.metadata.property.*;
import com.alibaba.excel.metadata.*;
import java.time.format.*;
/**
 * 日期类型转换
 * @author Magic
 *
 */
public class LocalDateConverter implements Converter<LocalDate>
{
    public Class<LocalDate> supportJavaTypeKey() {
        return LocalDate.class;
    }

    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    public LocalDate convertToJavaData(final CellData cellData, final ExcelContentProperty contentProperty, final GlobalConfiguration globalConfiguration) {
        return LocalDate.parse(cellData.getStringValue(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    }

    public CellData<String> convertToExcelData(final LocalDate value, final ExcelContentProperty contentProperty, final GlobalConfiguration globalConfiguration) {
        return (CellData<String>)new CellData(value.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
    }
}
